Add creation functions for actions.
authorMatthias Clasen <maclas@gmx.de>
Wed, 7 Jan 2004 21:54:33 +0000 (21:54 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 7 Jan 2004 21:54:33 +0000 (21:54 +0000)
Wed Jan  7 22:20:20 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkaction.h:
* gtk/gtkaction.c (gtk_action_new):
* gtk/gtktoggleaction.h:
* gtk/gtktoggleaction.c (gtk_toggle_action_new):
* gtk/gtkradioaction.h:
* gtk/gtkradioaction.c (gtk_radio_action_new): Add creation
functions for actions.

* gtk/gtkactiongroup.c (gtk_action_group_add_actions_full):
(gtk_action_group_add_toggle_actions_full):
(gtk_action_group_add_radio_actions_full): and use the
new functions here.  (#125322, Patch by Jeff Frank)

14 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtkaction.c
gtk/gtkaction.h
gtk/gtkactiongroup.c
gtk/gtkradioaction.c
gtk/gtkradioaction.h
gtk/gtktoggleaction.c
gtk/gtktoggleaction.h

index 037d65c01a7f15399f3680610f3d8e393c1a19ee..ba65c03fdfc374a18942bde09c2f739c99cd1606 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Wed Jan  7 22:20:20 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.h: 
+       * gtk/gtkaction.c (gtk_action_new):  
+       * gtk/gtktoggleaction.h: 
+       * gtk/gtktoggleaction.c (gtk_toggle_action_new): 
+       * gtk/gtkradioaction.h: 
+       * gtk/gtkradioaction.c (gtk_radio_action_new): Add creation 
+       functions for actions.
+
+       * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full): 
+       (gtk_action_group_add_toggle_actions_full): 
+       (gtk_action_group_add_radio_actions_full): and use the
+       new functions here.  (#125322, Patch by Jeff Frank)
+
 Wed Jan  7 21:42:49 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkaccelmap.c (gtk_accel_map_lock_path): Fix grammar of 
index 037d65c01a7f15399f3680610f3d8e393c1a19ee..ba65c03fdfc374a18942bde09c2f739c99cd1606 100644 (file)
@@ -1,3 +1,18 @@
+Wed Jan  7 22:20:20 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.h: 
+       * gtk/gtkaction.c (gtk_action_new):  
+       * gtk/gtktoggleaction.h: 
+       * gtk/gtktoggleaction.c (gtk_toggle_action_new): 
+       * gtk/gtkradioaction.h: 
+       * gtk/gtkradioaction.c (gtk_radio_action_new): Add creation 
+       functions for actions.
+
+       * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full): 
+       (gtk_action_group_add_toggle_actions_full): 
+       (gtk_action_group_add_radio_actions_full): and use the
+       new functions here.  (#125322, Patch by Jeff Frank)
+
 Wed Jan  7 21:42:49 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkaccelmap.c (gtk_accel_map_lock_path): Fix grammar of 
index 037d65c01a7f15399f3680610f3d8e393c1a19ee..ba65c03fdfc374a18942bde09c2f739c99cd1606 100644 (file)
@@ -1,3 +1,18 @@
+Wed Jan  7 22:20:20 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.h: 
+       * gtk/gtkaction.c (gtk_action_new):  
+       * gtk/gtktoggleaction.h: 
+       * gtk/gtktoggleaction.c (gtk_toggle_action_new): 
+       * gtk/gtkradioaction.h: 
+       * gtk/gtkradioaction.c (gtk_radio_action_new): Add creation 
+       functions for actions.
+
+       * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full): 
+       (gtk_action_group_add_toggle_actions_full): 
+       (gtk_action_group_add_radio_actions_full): and use the
+       new functions here.  (#125322, Patch by Jeff Frank)
+
 Wed Jan  7 21:42:49 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkaccelmap.c (gtk_accel_map_lock_path): Fix grammar of 
index 037d65c01a7f15399f3680610f3d8e393c1a19ee..ba65c03fdfc374a18942bde09c2f739c99cd1606 100644 (file)
@@ -1,3 +1,18 @@
+Wed Jan  7 22:20:20 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.h: 
+       * gtk/gtkaction.c (gtk_action_new):  
+       * gtk/gtktoggleaction.h: 
+       * gtk/gtktoggleaction.c (gtk_toggle_action_new): 
+       * gtk/gtkradioaction.h: 
+       * gtk/gtkradioaction.c (gtk_radio_action_new): Add creation 
+       functions for actions.
+
+       * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full): 
+       (gtk_action_group_add_toggle_actions_full): 
+       (gtk_action_group_add_radio_actions_full): and use the
+       new functions here.  (#125322, Patch by Jeff Frank)
+
 Wed Jan  7 21:42:49 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkaccelmap.c (gtk_accel_map_lock_path): Fix grammar of 
index 037d65c01a7f15399f3680610f3d8e393c1a19ee..ba65c03fdfc374a18942bde09c2f739c99cd1606 100644 (file)
@@ -1,3 +1,18 @@
+Wed Jan  7 22:20:20 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkaction.h: 
+       * gtk/gtkaction.c (gtk_action_new):  
+       * gtk/gtktoggleaction.h: 
+       * gtk/gtktoggleaction.c (gtk_toggle_action_new): 
+       * gtk/gtkradioaction.h: 
+       * gtk/gtkradioaction.c (gtk_radio_action_new): Add creation 
+       functions for actions.
+
+       * gtk/gtkactiongroup.c (gtk_action_group_add_actions_full): 
+       (gtk_action_group_add_toggle_actions_full): 
+       (gtk_action_group_add_radio_actions_full): and use the
+       new functions here.  (#125322, Patch by Jeff Frank)
+
 Wed Jan  7 21:42:49 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkaccelmap.c (gtk_accel_map_lock_path): Fix grammar of 
index 0834d38e83d16d3c44e078d0ad5af31681d08159..10dc918aad2051c4a385fd43860e6d115a6a5194 100644 (file)
@@ -1,3 +1,8 @@
+Wed Jan  7 22:25:45 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtk-sections.txt: Add gtk_action_new, gtk_toggle_action_new,
+       gtk_radio_action_new, gtk_action_group_add_action_with_accel.
+
 Wed Jan  7 01:56:33 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gdk-pixbuf/tmpl/file-saving.sgml: Document GdkPixbufSaveFunc.
index 66d918f0515247ca28c00077dde436368af69bd8..a5531ebf2b2de168372acb31f69945e779be6aed 100644 (file)
@@ -102,6 +102,7 @@ gtk_accessible_get_type
 <FILE>gtkaction</FILE>
 <TITLE>GtkAction</TITLE>
 GtkAction
+gtk_action_new
 gtk_action_get_name
 gtk_action_activate
 gtk_action_create_icon
@@ -138,6 +139,7 @@ gtk_action_group_get_name
 gtk_action_group_get_action
 gtk_action_group_list_actions
 gtk_action_group_add_action
+gtk_action_group_add_action_with_accel
 gtk_action_group_remove_action
 GtkActionEntry
 gtk_action_group_add_actions
@@ -2325,6 +2327,7 @@ gtk_progress_bar_get_type
 <FILE>gtkradioaction</FILE>
 <TITLE>GtkRadioAction</TITLE>
 GtkRadioAction
+gtk_radio_action_new
 gtk_radio_action_get_group
 gtk_radio_action_set_group
 gtk_radio_action_get_current_value
@@ -3107,6 +3110,7 @@ gtk_tips_query_get_type
 <FILE>gtktoggleaction</FILE>
 <TITLE>GtkToggleAction</TITLE>
 GtkToggleAction
+gtk_toggle_action_new
 gtk_toggle_action_toggled
 gtk_toggle_action_set_active
 gtk_toggle_action_get_active
index b0db28361af66c697bc40414cc92f02ba30d5913..20c2dbe1f7fbab69fb4e1b94d66a05a7223ef31d 100644 (file)
@@ -359,6 +359,39 @@ gtk_action_init (GtkAction *action)
   action->private_data->proxies = NULL;
 }
 
+/**
+ * gtk_action_new:
+ * @name: A unique name for the action
+ * @label: the label displayed in menu items and on buttons
+ * @tooltip: a tooltip for the action
+ * @stock_id: the stock icon to display in widgets representing the action
+ *
+ * Creates a new #GtkAction object. To add the action to a
+ * #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: a new #GtkAction
+ *
+ * Since: 2.4
+ */
+GtkAction *
+gtk_action_new (const gchar *name,
+               const gchar *label,
+               const gchar *tooltip,
+               const gchar *stock_id)
+{
+  GtkAction *action;
+
+  action = g_object_new (GTK_TYPE_ACTION,
+                        "name", name,
+                        "label", label,
+                        "tooltip", tooltip,
+                        "stock_id", stock_id,
+                        NULL);
+
+  return action;
+}
+
 static void
 gtk_action_finalize (GObject *object)
 {
index e855052d679c4149f5a411c062e47fa523c5cc86..34cec2cda3b626913ac28700923f6e5788f69d8b 100644 (file)
@@ -81,6 +81,10 @@ struct _GtkActionClass
 };
 
 GType        gtk_action_get_type               (void);
+GtkAction   *gtk_action_new                    (const gchar *name,
+                                               const gchar *label,
+                                               const gchar *tooltip,
+                                               const gchar *stock_id);
 const gchar* gtk_action_get_name               (GtkAction     *action);
 void         gtk_action_activate               (GtkAction     *action);
 GtkWidget*   gtk_action_create_icon            (GtkAction     *action,
index bac151efdc5ffd4107a53c20d10d8b2b2037100d..6389db80f30bb30813c95e43cbd8832a36542a79 100644 (file)
@@ -296,19 +296,20 @@ gtk_action_group_add_action (GtkActionGroup *action_group,
 /**
  * gtk_action_group_add_action_with_accel:
  * @action_group: the action group (#GtkActionGroup)
- * @action : the action to add (#GtkAction)
- * @name :
- * @accelerator :
- * @stock_id :
+ * @action: the action to add (#GtkAction)
+ * @name: the name of the action to add
+ * @accelerator: the accelerator for the action, in
+ *   the format understood by gtk_accelerator_parse().
+ * @stock_id: the stock icon to display
  *
  * Adds an action object to the action group and sets up the accelerator.
  *
- * If @accelerator is NULL, attempt to use the accelerator associated with
+ * If @accelerator is %NULL, attempt to use the accelerator associated with
  * @stock_id.
  *
- * accel paths are set to 
- * <literal>&lt;Actions&gt;/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.  
- * 
+ * Accel paths are set to
+ * <literal>&lt;Actions&gt;/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
+ *
  * Since: 2.4
  */
 void
@@ -476,12 +477,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
          tooltip = entries[i].tooltip;
        }
 
-      action = g_object_new (GTK_TYPE_ACTION,
-                            "name", entries[i].name,
-                            "label", label,
-                            "tooltip", tooltip,
-                            "stock_id", entries[i].stock_id,
-                            NULL);
+      action = gtk_action_new (entries[i].name,
+                              label,
+                              tooltip,
+                              entries[i].stock_id);
 
       if (entries[i].callback)
        g_signal_connect_data (action, "activate",
@@ -558,7 +557,7 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup       *action_group,
 
   for (i = 0; i < n_entries; i++)
     {
-      GtkAction *action;
+      GtkToggleAction *action;
       const gchar *label;
       const gchar *tooltip;
 
@@ -573,22 +572,20 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup       *action_group,
          tooltip = entries[i].tooltip;
        }
 
-      action = g_object_new (GTK_TYPE_TOGGLE_ACTION,
-                            "name", entries[i].name,
-                            "label", label,
-                            "tooltip", tooltip,
-                            "stock_id", entries[i].stock_id,
-                            NULL);
+      action = gtk_toggle_action_new (entries[i].name,
+                                     label,
+                                     tooltip,
+                                     entries[i].stock_id);
 
-      gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), 
-                                   entries[i].is_active);
+      gtk_toggle_action_set_active (action, entries[i].is_active);
 
       if (entries[i].callback)
        g_signal_connect_data (action, "activate",
                               entries[i].callback, 
                               user_data, (GClosureNotify)destroy, 0);
 
-      gtk_action_group_add_action_with_accel (action_group, action,
+      gtk_action_group_add_action_with_accel (action_group, 
+                                             action,
                                              entries[i].name,
                                              entries[i].accelerator,
                                              entries[i].stock_id);
@@ -670,7 +667,7 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup      *action_group,
 
   for (i = 0; i < n_entries; i++)
     {
-      GtkAction *action;
+      GtkRadioAction *action;
       const gchar *label;
       const gchar *tooltip; 
 
@@ -685,24 +682,23 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup      *action_group,
          tooltip = entries[i].tooltip;
        }
 
-      action = g_object_new (GTK_TYPE_RADIO_ACTION,
-                            "name", entries[i].name,
-                            "label", label,
-                            "tooltip", tooltip,
-                            "stock_id", entries[i].stock_id,
-                            "value", entries[i].value,
-                            NULL);
+      action = gtk_radio_action_new (entries[i].name,
+                                    label,
+                                    tooltip,
+                                    entries[i].stock_id,
+                                    value);
 
       if (i == 0) 
        first_action = action;
 
-      gtk_radio_action_set_group (GTK_RADIO_ACTION (action), group);
-      group = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
+      gtk_radio_action_set_group (action, group);
+      group = gtk_radio_action_get_group (action);
 
       if (value == entries[i].value)
-       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+       gtk_toggle_action_set_active (action, TRUE);
 
-      gtk_action_group_add_action_with_accel (action_group, action,
+      gtk_action_group_add_action_with_accel (action_group, 
+                                             action,
                                              entries[i].name,
                                              entries[i].accelerator,
                                              entries[i].stock_id);
index e6ae027425be51a411f381428a33e0847459a3ac..35460a33b815ec6a9f02fc0c374bb4d3f936fb7b 100644 (file)
@@ -171,6 +171,43 @@ gtk_radio_action_init (GtkRadioAction *action)
   action->private_data->value = 0;
 }
 
+/**
+ * gtk_radio_action_new:
+ * @name: A unique name for the action
+ * @label: The label displayed in menu items and on buttons
+ * @tooltip: A tooltip for this action
+ * @stock_id: The stock icon to display in widgets representing this action
+ * @value: The value which gtk_radio_action_get_current_value() should return
+ *    if this action is selected.
+ *
+ * Creates a new #GtkRadioAction object. To add the action to
+ * a #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: a new #GtkRadioAction
+ *
+ * Since: 2.4
+ */
+GtkRadioAction *
+gtk_radio_action_new (const gchar *name,
+                     const gchar *label,
+                     const gchar *tooltip,
+                     const gchar *stock_id,
+                     gint value)
+{
+  GtkRadioAction *action;
+
+  action = g_object_new (GTK_TYPE_RADIO_ACTION,
+                        "name", name,
+                        "label", label,
+                        "tooltip", tooltip,
+                        "stock_id", stock_id,
+                        "value", value,
+                        NULL);
+
+  return action;
+}
+
 static void
 gtk_radio_action_finalize (GObject *object)
 {
index 3617a239b2b8f43839a7959a2d43efca84dc8ad3..b1de074c5d0e986659eb8f03bbf2a5d7732d4f43 100644 (file)
@@ -67,12 +67,17 @@ struct _GtkRadioActionClass
   void (*_gtk_reserved4) (void);
 };
 
-GType    gtk_radio_action_get_type          (void);
+GType           gtk_radio_action_get_type          (void);
+GtkRadioAction *gtk_radio_action_new               (const gchar           *name,
+                                                    const gchar           *label,
+                                                    const gchar           *tooltip,
+                                                    const gchar           *stock_id,
+                                                    gint                   value);
+GSList         *gtk_radio_action_get_group         (GtkRadioAction        *action);
+void            gtk_radio_action_set_group         (GtkRadioAction        *action,
+                                                    GSList                *group);
+gint            gtk_radio_action_get_current_value (GtkRadioAction        *action);
 
-GSList  *gtk_radio_action_get_group         (GtkRadioAction *action);
-void     gtk_radio_action_set_group         (GtkRadioAction *action,
-                                            GSList         *group);
-gint     gtk_radio_action_get_current_value (GtkRadioAction *action);
 
 G_END_DECLS
 
index c3ac2d71f65ad7e48f109bc0b1e567104e891356..1f4a8d7a03dc92c58fc6d753323efc694df2ffad 100644 (file)
@@ -151,6 +151,39 @@ gtk_toggle_action_init (GtkToggleAction *action)
   action->private_data->draw_as_radio = FALSE;
 }
 
+/**
+ * gtk_toggle_action_new:
+ * @name: A unique name for the action
+ * @label: The label displayed in menu items and on buttons
+ * @tooltip: A tooltip for the action
+ * @stock_id: The stock icon to display in widgets representing the action
+ *
+ * Creates a new #GtkToggleAction object. To add the action to
+ * a #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: a new #GtkToggleAction
+ *
+ * Since: 2.4
+ */
+GtkToggleAction *
+gtk_toggle_action_new (const gchar *name,
+                      const gchar *label,
+                      const gchar *tooltip,
+                      const gchar *stock_id)
+{
+  GtkToggleAction *action;
+
+  action = g_object_new (GTK_TYPE_TOGGLE_ACTION,
+                        "name", name,
+                        "label", label,
+                        "tooltip", tooltip,
+                        "stock_id", stock_id,
+                        NULL);
+
+  return action;
+}
+
 static void
 get_property (GObject     *object,
              guint        prop_id,
@@ -170,7 +203,6 @@ get_property (GObject     *object,
     }
 }
 
-
 static void
 set_property (GObject      *object,
              guint         prop_id,
index 0b7b4180c7d0eb99371eea438e4d192178da1c89..03183bf531827426692f50d77b02c2482c71ef1c 100644 (file)
@@ -67,14 +67,19 @@ struct _GtkToggleActionClass
   void (*_gtk_reserved4) (void);
 };
 
-GType    gtk_toggle_action_get_type          (void);
-void     gtk_toggle_action_toggled           (GtkToggleAction *action);
-void     gtk_toggle_action_set_active        (GtkToggleAction *action,
-                                             gboolean         is_active);
-gboolean gtk_toggle_action_get_active        (GtkToggleAction *action);
-void     gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
-                                             gboolean         draw_as_radio);
-gboolean gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action);
+GType            gtk_toggle_action_get_type          (void);
+GtkToggleAction *gtk_toggle_action_new               (const gchar     *name,
+                                                      const gchar     *label,
+                                                      const gchar     *tooltip,
+                                                      const gchar     *stock_id);
+void             gtk_toggle_action_toggled           (GtkToggleAction *action);
+void             gtk_toggle_action_set_active        (GtkToggleAction *action,
+                                                      gboolean         is_active);
+gboolean         gtk_toggle_action_get_active        (GtkToggleAction *action);
+void             gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
+                                                      gboolean         draw_as_radio);
+gboolean         gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action);
+
 
 G_END_DECLS